package com.redxiii.tracplus.ejb.session;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 * @author Daniel Filgueiras
 * @since 19/08/2011
 */
@SuppressWarnings("deprecation")
public class HibernateUtil {
	
	private static final SessionFactory sessionFactory;
	
	static {
		try {
			sessionFactory = new AnnotationConfiguration()
									.configure("/META-INF/hibernate.cfg.xml")
									.buildSessionFactory();		//FIXME Why deprecated ?
		} catch (Throwable ex) {
			throw new ExceptionInInitializerError(ex);
		}
	}
	
	public static Session getSession() {
		return sessionFactory.openSession();
	}
}
